//
//  LoadingView.m
//  Longing封装
//
//  Created by 常宽 on 14/11/11.
//  Copyright (c) 2014年 常宽. All rights reserved.
//

#import "LoadingView.h"

@interface LoadingView ()
@property (nonatomic, retain)UIView *bomm;
@property (nonatomic, retain)UIImageView *myLoadingView;
@property (nonatomic, retain)NSMutableArray *imageArray;
@end

@implementation LoadingView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.imageArray = [NSMutableArray array];
        for (int i = 0; i < 41; i ++) {
            UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"Load_%d.png", i]];
            [_imageArray addObject:image];
        }        
        self.bomm = [[UIView alloc]init];
        [self addSubview:_bomm];
        [self sendSubviewToBack:_bomm];
        [_bomm release];
        
        self.myLoadingView = [[UIImageView alloc] init];
        [self addSubview:_myLoadingView];
        [_myLoadingView release];
    }
    return self;
}

- (void)dealloc
{
    [_imageArray release];
    [_bomm release];
    [_myLoadingView release];
    [super dealloc];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    
    
    _bomm.frame = self.frame;
//    _bomm.alpha = 0.8;
    _bomm.backgroundColor = [UIColor whiteColor];
    
    _myLoadingView.frame = CGRectMake(0, 0, 160, 180);
    _myLoadingView.clipsToBounds = YES;
    _myLoadingView.contentMode = UIViewContentModeScaleAspectFill;
    _myLoadingView.backgroundColor = [UIColor whiteColor];
    _myLoadingView.center = CGPointMake(_bomm.center.x, _bomm.center.y - 20);
    _myLoadingView.animationImages = _imageArray;
    _myLoadingView.animationDuration = 2;
    [_myLoadingView startAnimating];
}




@end
